#ifndef FILEHANDLER_H
#define FILEHANDLER_H

#include <iostream>
#include <fstream>
#include "result.h"
#include "wine.h"

/**
 * @brief The FileHandler class
 *
 * Class for txt file operations
 *
 * Includes functions for:
 * -reading starting weights from configuration txt file
 * -writing results to txt file
 */
class FileHandler{
public:

    FileHandler(std::string& outFile){outputStream.open(outFile);}
    ~FileHandler();

    bool readConfigForWeightVectors(const std::string& fileName,std::vector<std::vector<double> >& weightVectors);

    void updateOriginalWeights(std::vector<double>& weights);

    void updateResultFile(const std::string& info, std::vector<double>& weights, Result& best,int k, Result& main_result);

    void nextChapterInResultFile(const std::string& s);

private:
    std::vector<std::string> split(std::string &s, char delim);
    std::vector<std::string> &splitSecond(std::string &s, char delim, std::vector<std::string> &elems);

    std::ofstream outputStream;



};

#endif // FILEHANDLER_H
